//
//  CLLocation+Format.m
//  RobNewGrain
//
//  Created by 唐可雄 on 16/8/9.
//  Copyright © 2016年 swustyc. All rights reserved.
//

#import "CLLocation+Format.h"

@implementation CLLocation (Format)

- (NSString *)distanceStrFromLocation:(CLLocation *)location {
    double distance = [self distanceFromLocation:location];
    
    if (distance < 0) {
        distance = -distance;
    }
    
    if (distance < 1000) {
        return [NSString stringWithFormat:@"%@m", @((int)distance)];
    } else {
        return [NSString stringWithFormat:@"%.01lfkm", distance/1000];
    }
}

@end
